package shop.maytinh.view;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

import org.apache.struts2.ServletActionContext;

import shop.maytinh.model.Category;
import shop.maytinh.model.Member;
import shop.maytinh.model.Product;
import shop.maytinh.model.Factory;
import shop.maytinh.model.vo.Card;
import shop.maytinh.util.KPaging;
import shop.maytinh.controller.CatalogiesManager;
import shop.maytinh.controller.FactoryManager;
import shop.maytinh.controller.ProductManager;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.Preparable;


public class AbstractClass extends ActionSupport implements Preparable{
	protected HttpServletRequest request;
	protected HttpServletResponse response;
	protected HttpSession session;
	

	Member member;
	
	List<Category> lstCatalogies ;
	List<Factory> lstFactory;
	ArrayList<Product> array;
	List<Product> lstProductfastsell;
	
	
	
	private String currentUrl;
	public HttpServletRequest getRequest() {
		return request;
	}
	@Override
	public void prepare() throws Exception {
		this.request = ServletActionContext.getRequest();
		this.request.setCharacterEncoding("UTF-8");
		this.response = ServletActionContext.getResponse();
		this.session = this.request.getSession(true);
		
		if(this.request != null){
			this.currentUrl = this.request.getServletPath();
		}
		if(request.getSession().getAttribute("Member") != null){
			member = (Member)request.getSession().getAttribute("Member");			
		}
		
		CatalogiesManager catmn =  new CatalogiesManager();
		lstCatalogies = catmn.getlistCategory();
		
		FactoryManager fcmn = new FactoryManager();
		lstFactory = fcmn.getlistFactory();
		

		ProductManager prmn = new ProductManager();
		array = prmn.getlistidproductfastsell();
		lstProductfastsell = array;
		
		
	}

	public Member getMember() {
		return member;
	}

	public void setMember(Member member) {
		this.member = member;
	}
	public String getCurrentUrl() {
		return currentUrl;
	}

	public void setCurrentUrl(String currentUrl) {
		this.currentUrl = currentUrl;
	}
	public List<Category> getLstCatalogies() {
		return lstCatalogies;
	}
	public void setLstCatalogies(List<Category> lstCatalogies) {
		this.lstCatalogies = lstCatalogies;
	}
	public List<Factory> getLstFactory() {
		return lstFactory;
	}
	public void setLstFactory(List<Factory> lstFactory) {
		this.lstFactory = lstFactory;
	}
	public List<Product> getLstProductfastsell() {
		return lstProductfastsell;
	}
	public void setLstProductfastsell(List<Product> lstProductfastsell) {
		this.lstProductfastsell = lstProductfastsell;
	}
	
}
